<?php  
namespace app\admin\controller;
use think\Controller;
class Admin extends Controller{
	public function admin_list(){
		$arr=db('admin')->paginate(5);
		return view('',['arr'=>$arr]);
	}
	public function login(){
		return view();
	}
	public function check(){
		// halt(input());
		$res=db('admin')->where('admin',$_POST['admin'])->where('password',$_POST['password'])->find();
		if(!captcha_check($_POST['captcha'])){
			$this->error('验证码错误','login');
		}
		if($res){
			session('adminname',$_POST['admin']);
			$time=$res['time']+1;
			$res=db('admin')->where('id',$res['id'])->update(['time'=>$time]);
			
			// $a=(session('?login_time'))?(session('login_time')+1):1;
			// session('login_time',$a);
			$this->success('登录成功','Index/index');
		}else{
			$this->error('登录失败','login');
		}
	}
	public function admin_exit(){
		session('adminname',null);
		$this->success('已退出','login');
	}
	public function admin_forbid(){
		$_GET['limit']='no';
		if(db('admin')->update($_GET)){
			$this->success('禁止成功','admin_list');
		}else{
			$this->error('禁止失败','admin_list');
		}
	}
	public function admin_recover(){
		$_GET['limit']='yes';
		if(db('admin')->update($_GET)){
			$this->success('恢复成功','admin_list');
		}else{
			$this->error('恢复失败','admin_list');
		}
	}
}
?>